package com.yunhe.inspect.client;

import com.yunhe.common.exception.ArgumentErrorException;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.Organization;
import com.yunhe.common.model.authority.RealStation;
import com.yunhe.common.model.authority.User;
import com.yunhe.common.model.inspect.RealStationOfficeCompanyVo;
import com.yunhe.inspect.client.fallback.AuthorityClientFallbackFactory;
import com.yunhe.inspect.config.FeignConfig;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @ClassName AuthorityClient
 * @Description TODO
 * @Author HeTao
 * @Date 2021/11/9 16:22
 * @Version 1.0
 **/
@ApiIgnore
@FeignClient(value = "yh-authority", fallbackFactory = AuthorityClientFallbackFactory.class,configuration = FeignConfig.class)
@Component
public interface AuthorityClient  {

    @RequestMapping(value = "/organization/getSubOrgByLoginUser", method = RequestMethod.GET)
    public ResponseEntity<ResultObject<List<Organization>>> getSubOrgByLoginUser(@RequestParam(value = "stationId",required = true) Long stationId,
                                                                                 @RequestParam(value = "userId",required = true) Long userId,
                                                                                 @RequestParam(value = "childFlag",required = true) Boolean childFlag) throws ArgumentErrorException;

    /**
     * 根据项目id或单位id查询组织列表
     * @param stationId 项目ID
     */
    @ApiOperation("根据项目id或单位id查询组织列表")
    @RequestMapping(value = "/organization/searchOrgByStationIdOrFirmId", method = RequestMethod.GET)
    ResponseEntity<ResultObject<List<Organization>>> searchOrgByStationId(@RequestParam(value = "stationId",required = false) Long stationId,
                                                      @RequestParam(value = "firmId",required = false) Long firmId);

    @RequestMapping(value = "/realStation/searchStationAndOfficeAndCompanyByStationId/{stationId}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<List<RealStationOfficeCompanyVo>>> searchStationAndOfficeAndCompanyByStationId(@PathVariable("stationId") Long stationId);

    @RequestMapping(value = "/realStation/searchStationAndOfficeAndCompany", method = RequestMethod.POST)
    ResponseEntity<ResultObject<List<RealStationOfficeCompanyVo>>> searchStationAndOfficeAndCompany(@RequestBody List<String> value);

    /**
     * 根据ID获得用户对象
     *
     * @param id 用户ID
     */
    @RequestMapping(value = "/users/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<User>> getUserById(@RequestParam("id") Long id);


}
